from myutil.mysql_diver import mysql_diver
from myutil import globalvar as gl, logs
from myutil.ssh_diver import ssh_diver


def __init():
    mysql_connect(host="wp19991.cn", port="3306", database="jwc_db", user="root", password="******")
    ssh_connect(host="wp19991.cn", port="22", user="root", password="******")
    gl.set_value("app_version", "v2.4")


def mysql_connect(host, port, database, user, password):
    try:
        a = mysql_diver(host=host, port=port, database=database, user=user, password=password)
        if not a.status:
            b = 1 / 0
        gl.set_value("mysql_diver", a)
        logs.logs_print("数据库连接成功")
    except:
        logs.logs_print("数据库连接失败")


def ssh_connect(host, port, user, password):
    try:
        a = ssh_diver(host=host, port=port, user=user, password=password)
        gl.set_value("ssh_diver", a)
        logs.logs_print("ssh连接成功")
    except:
        logs.logs_print("ssh连接失败")
